<%@ page import="com.iweb.constant.ShoppingCartAction" %>
<%@ page import="com.iweb.constant.CartItemChangeEnum" %>
<%@ page import="com.iweb.constant.MyConstant" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
  <base href="<%=basePath%>">
  <title>购物车</title>
  <!-- bootstrap & fontawesome -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style"/>
  <link rel="stylesheet" href="assets/css/ace-skins.min.css"/>
</head>
<body>
<div class="row">
  <div class="col-sm-12">
    <table class="table table-bordered">
      <thead>
      <tr>
        <th>商品名称</th>
        <th>单价</th>
        <th>数量</th>
        <th>小计</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <c:forEach items="${sessionScope.shoppingCart.itemList}" var="item">
        <tr>
          <td><img height="80px" src="assets/upload/${item.photo}" alt=""> ${item.productName}</td>
          <td>${item.price}</td>
          <td>
            <a href="front/shoppingCart.do?action=<%=ShoppingCartAction.CHANGEAMOUNT%>&productId=${item.productId}&option=<%=CartItemChangeEnum.reduce%>"
               class="btn btn-default btn-sm">-</a>
              ${item.amount}
            <a href="front/shoppingCart.do?action=<%=ShoppingCartAction.CHANGEAMOUNT%>&productId=${item.productId}&option=<%=CartItemChangeEnum.add%>"
               class="btn btn-default btn-sm">+</a>
          </td>
          <td>${item.sum}</td>
          <td><a href="front/shoppingCart.do?action=remove&productId=${item.productId}">删除</a></td>
        </tr>
      </c:forEach>
      <tr>
        <td colspan="4" class="text-right">合计:${sessionScope.shoppingCart.totalPrice}元</td>
        <td colspan="4"><a href="front/shoppingCart.do?action=<%=ShoppingCartAction.PAY%>"
                           class="btn btn-danger">去结算</a></td>
      </tr>
      </tbody>
    </table>
    <p>${requestScope.errorMessage}</p>
  </div>
</div>
</body>
</html>
